const app = getApp();
Page({
    data: {
        active: 0,
        videoList: [],
        messageList: []
    },
    onLoad() {
        this.getvideoList()
        this.getMessage()
    },
    getvideoList() {
        app.get("/video/list").then(res => {
            this.setData({
                    videoList: res.data
                })
            }).catch(err => {
                console.log(err);
        })
    },
    getMessage() {
        app.get("/info/list").then(res => {
            this.setData({
                messageList: res.data
            })
        })
    },
    onChange(event) {
        let index = event.detail.index
        this.setData({
            active: index
        })
    },
    toDetail(event){
        //获取点击对象的下标
        console.log(event.target);
        let index= event.target.dataset.index;
        // 获取点击对象下标的数据
        let obj=this.data.videoList[index]
        // 将obj对象转化成字符串
        let objstr = JSON.stringify(obj)
        wx.navigateTo({
            url: './detail?objstr='+objstr,
          })
    }
})